import {createApp} from 'vue'

import Cookies from 'js-cookie'

import ElementPlus from 'element-plus'
import locale from 'element-plus/lib/locale/lang/zh-cn' // 中文语言
import '@/assets/styles/index.scss' // global css
import App from './App'
import store from './store'
import router from './router'

router.afterEach((to,from,next)=>{
  // document.querySelector("body").setAttribute("style","overflow: auto !important;")
})

import directive from './directive' // directive
// 注册指令
import plugins from './plugins' // plugins
import {download,exportExcelByWeb} from '@/utils/request'
import {
  formatAmountEmpty,
  formartNumber,
  formartTableP2,
  formartTableP4,
  formartFormP4,
  formartTablePercentP4,
  formartTablePercentP2,
  formartTablePercentP3,
  formartEmptyTableP2,
  formartEmptyTablePercentP2
} from '@/utils/numberUtil'
import {isVoid, isNotVoid} from "@/utils/util";
// svg图标
import 'virtual:svg-icons-register'
import SvgIcon from '@/components/SvgIcon'
import elementIcons from '@/components/SvgIcon/svgicon'

import './permission' // permission control
import {useDict} from '@/utils/dict'
import {
  addDateRange,
  handleTree,
  parseTime,
  resetForm,
  selectDictLabel,
  getCurrTime,
  getSysDate,
  getSummary,
  columnsCal,
  treeFindPath
} from '@/utils/xquant'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
// 分页组件
import Pagination from '@/components/Pagination'
// 自定义表格工具组件
import RightToolbar from '@/components/RightToolbar'
// 文件上传组件
import FileUpload from "@/components/FileUpload"
// 图片上传组件
import ImageUpload from "@/components/ImageUpload"
// 图片预览组件
import ImagePreview from "@/components/ImagePreview"
// 自定义树选择组件
import TreeSelect from '@/components/TreeSelect'
// 自定义多选树选择组件
import TreeMultipleSelect from '@/components/TreeMultipleSelect'
// 字典标签组件
import DictTag from '@/components/DictTag'


// 自定义样式
import '@/assets/styles/xir.scss' // xir.scss

import lodash from 'lodash'

import xTable from "@/xquant/base/xTable";
import baseCombox from "@/xquant/base/baseCombox";
import dictCombox from "@/xquant/base/dictCombox"
import underlyer from "@/xquant/base/underlyer";
import number from "@/xquant/base/number";

import xCalendar from "@/xquant/base/xCalendar"

/*报价版ui依赖*/
import NutUI from "@nutui/nutui";
import "@nutui/nutui/dist/style.css";
// 引入模块后自动生效
import '@vant/touch-emulator';


import Vant from 'vant';
import 'vant/lib/index.css';



const app = createApp(App)

app.use(Vant);
// 全局方法挂载
app.config.globalProperties.useDict = useDict
app.config.globalProperties.download = download
app.config.globalProperties.exportExcel = exportExcelByWeb
app.config.globalProperties.parseTime = parseTime
app.config.globalProperties.resetForm = resetForm
app.config.globalProperties.handleTree = handleTree
app.config.globalProperties.addDateRange = addDateRange
app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.formatAmountEmpty=formatAmountEmpty
app.config.globalProperties.formartNumber = formartNumber
app.config.globalProperties.formartFormP4 = formartFormP4
app.config.globalProperties.formartTableP2 = formartTableP2
app.config.globalProperties.formartTableP4 = formartTableP4
app.config.globalProperties.formartTablePercentP4 = formartTablePercentP4
app.config.globalProperties.formartTablePercentP2 = formartTablePercentP2
app.config.globalProperties.formartEmptyTableP2 = formartEmptyTableP2
app.config.globalProperties.formartEmptyTablePercentP2=formartEmptyTablePercentP2
app.config.globalProperties.getSysDate = getSysDate
app.config.globalProperties.getCurrTime = getCurrTime
app.config.globalProperties.getSummary = getSummary
app.config.globalProperties.columnsCal = columnsCal
app.config.globalProperties.treeFindPath = treeFindPath
app.config.globalProperties.isVoid = isVoid
app.config.globalProperties.isNotVoid = isNotVoid
// 全局组件挂载
app.component('DictTag', DictTag)
app.component('Pagination', Pagination)
app.component('TreeSelect', TreeSelect)
app.component('TreeMultipleSelect', TreeMultipleSelect)

app.component('FileUpload', FileUpload)
app.component('ImageUpload', ImageUpload)
app.component('ImagePreview', ImagePreview)
app.component('RightToolbar', RightToolbar)
// 全局自定义组件挂载
app.component('xTable', xTable)
app.component('baseCombox', baseCombox)
app.component('dictCombox', dictCombox)
app.component('underlyer', underlyer)
app.component('number', number)

app.component('xCalendar', xCalendar)
/*报价版ui依赖*/
app.use(NutUI)
app.use(lodash)
app.use(router)
app.use(store)
app.use(VXETable)
app.use(plugins)
app.use(elementIcons)
app.component('svg-icon', SvgIcon)
directive(app)

// 使用element-plus 并且设置全局的大小
app.use(ElementPlus, {
  locale: locale,
  size: Cookies.get('size') || 'small'
})

app.mount('#app')
const win = window

if (process.env.NODE_ENV === 'development') {

  if ('__VUE_DEVTOOLS_GLOBAL_HOOK__' in win) {

    win.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue = app

  }

}
